home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_12_01 / wingo / debugnew.cpp < prev   
C/C++ Source or Header  |  1993-11-08  |  479b  |  29 lines

  1. #include <stdlib.h>
  2. // MFC style debug new defines.
  3.  
  4. class CObject
  5. {
  6. public:
  7. #ifdef _DEBUG
  8.     // for file name/line number tracking using DEBUG_NEW
  9.     void* operator new(size_t nSize, char * lpszFileName, int nLine);
  10. #endif
  11. };
  12.  
  13. #ifdef _DEBUG
  14. // Memory tracking allocation
  15. #define DEBUG_NEW new(__FILE__, __LINE__)
  16. #else
  17. // NonDebug version that assume everything is OK
  18. #define DEBUG_NEW new
  19. #endif
  20.  
  21. #ifdef _DEBUG
  22. #define new DEBUG_NEW
  23. #endif
  24.  
  25. main()
  26. {
  27.     CObject *obj = new CObject;
  28. }
  29.